package com.xuhnagchen.automation.util;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class Log {
    private static Logger log;

    public static Logger getInstance(Class clazz) {
        if (log == null) {
            // 1. create log
            log = Logger.getLogger(clazz);
            // 2. get log config file
            PropertyConfigurator.configure("src/main/resources/log4j.properties");
        }

        return log;
    }

    public static void d(Class clazz,String value) {
        Logger log = Log.getInstance(clazz);
        log.debug(value);
    }

    public static void i(Class clazz,String value) {
        Logger log = Log.getInstance(clazz);
        log.info(value);
    }

    public static void w(Class clazz,String value) {
        Logger log = Log.getInstance(clazz);
        log.warn(value);
    }

    public static void e(Class clazz,String value) {
        Logger log = Log.getInstance(clazz);
        log.error(value);
    }

    public static void f(Class clazz,String value) {
        Logger log = Log.getInstance(clazz);
        log.fatal(value);
    }


    public static void main(String[] args) {
        // 1. create log
        Logger log = Logger.getLogger(Log.class);
        // 2. get log config file
        PropertyConfigurator.configure("src/main/resources/log4j.properties");
        // 3. start log
        log.debug("Here is some DEBUG");
        log.info("Here is some INFO");
        log.warn("Here is some WARN");
        log.error("Here is some ERROR");
        log.fatal("Here is some FATAL");
    }
}
